home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 175
/
175.d81
/
b.fox & hounds 2
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
224 lines
10 poke56,56:clr:dv=peek(186):ifdv<8ordv>29thendv=8
12 poke53371,0
20 sys57812"font2",dv,0:poke780,0:poke781,0:poke782,56:sys65493:poke53272,31
30 dv=peek(186):ifdv<8ordv>29thendv=8
40 sys57812"wh",dv,0:poke780,0:poke781,0:poke782,192:sys65493
50 gosub80:rem instructions fox and hounds floyd r kirk
60 gosub1910:rem choice
70 goto400
80 deffnt(x)=2^(x-1):b1$=" "
90 b$=" [157][157][157][157] ":r$="[177][187][167][170][157][157][157][157][175][178][174][163][144]":w$="[184][190][179][189][157][157][157][157][173][255]& [144]"
100 poke53280,15:poke53281,15:poke646,0:print""
110 gosub3000
120 print" [194]e either the fox or the hounds and"
130 print"play the computer, or play both sides."
140 print"[212]he sides alternate one move at a time"
150 print"to a connecting empty square. [212]he three"
160 print"white hounds win if they block the one"
170 print"red fox in the rightmost square by their";
180 print"20th move. [212]he fox wins all the rest,"
190 print"such as by reaching the leftmost square"
200 print"or even if trapped on the wrong square."
210 print" [212]he fox can move to any empty"
220 print"connecting square. [193] hound can move up,"
230 print"down, right, right-and-up, and"
240 print"right-and-down, but never to the left.":print
250 printtab(7);"[144]@[161]@[161]@ [182][181] [162][182][181]"
260 printtab(6);"[181][182][162][182][181][182][162] @[161] [161]@[161]"
270 printtab(5);"@[161]@[161]@[161]@[161]@ [182][162] [181][182][162]"
280 printtab(6);"[162][182][181][182][162][182][181]"
290 printtab(7);"@[161]@[161]@ [200]ound [198]ox"
300 printtab(5);"[212]he [194]oard [205]oves [205]oves":poke198,0
310 diml%(11,11),s%(165),r%(30,2),a%(165,11),w%(3)
320 i=1:forl=1to9:l1=fnt(l):form=l+1to10:m1=fnt(m)
330 forr=m+1to11:s%(i)=l1+m1+fnt(r):i=i+1:nextr,m,l
340 fori=1to30:forj=1to2:r%(i,j)=0:nextj,i
350 fori=1to11:forj=1to11:readl%(i,j):nextj,i
360 print" [208]ress a key"
370 getz$:ifz$=""then370
380 return
390 rem new game begins here
400 w%(1)=1:w%(2)=2:w%(3)=4:i0=1
410 b=int(rnd(0)*9)+3:ifb=4then410
420 gosub1470
430 rem main program loop
440 r=18:c=6:gosub1900:printi0
450 ifn=2thengosub1180:v=peek(49152+11*(s3-1)+b):x=(vand240)/16:y=vand15:goto740
460 f$="[133]":w%(0)=b:fori=1to3:ifw%(i)=11then520
470 forj=2to11:ifl%(w%(i),j)<>2then510
480 fork=0to3:ifw%(k)=jthenk=5
490 nextk:ifk>5then510
500 f$=f$+chr$(w%(i)+64):j=11
510 nextj
520 nexti
530 iff$="[133]"then1050
540 r=18:c=31:gosub1900:print"f1[144] [209]uit."
550 j=1:r=21:c=0:gosub1900:print"[200]ound moves from":poke 198,0
560 geta$:ifa$=""then560
570 ifa$>="[193]"thena$=chr$(asc(a$)-128)
580 fori=1tolen(f$):ifa$=mid$(f$,i,1)thenj=i+1:r=18:c=31:gosub1900:print" "
590 next:onjgoto560,1050,600,600,600
600 x=asc(a$)-64
610 r=21:c=17:gosub1900:printchr$(x+192);";"
620 f$="":forj=2to11:ifl%(x,j)<>2then660
630 fork=0to3:ifw%(k)=jthenk=5
640 nextk:ifk>5then660
650 f$=f$+chr$(j+64)
660 nextj
670 j=1:r=21:c=20:gosub1900:print"moves to ";:poke198,0
680 geta$:ifa$=""then680
690 ifa$>="[193]"thena$=chr$(asc(a$)-128)
700 fori=1tolen(f$):ifa$=mid$(f$,i,1)thenj=i+1
710 next:ifj=1then680
720 y=asc(a$)-64
730 r=21:c=0:gosub1900:printb1$
740 i=1
750 ifw%(i)=xthenw%(i)=y:goto770
760 i=i+1:ifi<4then750
770 z=x:gosub1780:printb$:z=y:gosub1780:printw$
780 gosub1180: rem legal move; what is white position index (s3)
790 ifn=1then970
800 f$="[133]":forj=1to11:ifl%(b,j)=0then840
810 fork=1to3:ifw%(k)=jthenk=5
820 next:ifk>5then840
830 f$=f$+chr$(j+64)
840 nextj
850 iff$="[133]"andb<>11then1050
860 iff$="[133]"then1060
870 r=18:c=31:gosub1900:print"f1[144] [209]uit."
880 r=21:c=0:gosub1900:print"[198]ox moves to":j=1:poke198,0
890 geta$:ifa$=""then890
900 ifa$>="[193]"thena$=chr$(asc(a$)-128)
910 fori=1tolen(f$):ifa$=mid$(f$,i,1)thenj=i+1:r=18:c=31:gosub1900:print" "
920 next:ifj=1then890
930 ifj=2then1060
940 r=21:c=0:gosub1900:printb1$
950 m4=asc(mid$(f$,j-1,1))-64:goto1010
960 rem what is reds best move, if any
970 gosub1230:ifm4=0andb=11then1060
980 ifm4=0then1050
990 rem red moves to m4
1000 r%(i0,1)=s3:r%(i0,2)=m4
1010 z=b:gosub1780:printb$:b=m4:z=b:gosub1780:printr$
1020 i0=i0+1:ifi0>20then1050
1030 ifb>1then440
1040 rem game ends
1050 r=21:c=0:gosub1900:print" [198]ox wins.";:w=1:goto1070
1060 r=21:c=0:gosub1900:print" [200]ounds win.";:w=-1:i=0
1070 ifn=1thenfori6=1toi0-1:s=r%(i6,1):m=r%(i6,2):a%(s,m)=a%(s,m)+w:next:rem fox learn
1080 print" [215]ant to play again? (y[144]/n[144])":poke198,0
1090 getz$:ifz$<>""then1140
1100 ifw=-1then1120
1110 z=b:gosub1780:printb$:poke53280,2:gosub1780:printr$:poke53280,15:goto1090
1120 i=i+1:ifi>3theni=1
1130 z=w%(i):gosub1780:printb$:poke53280,1:gosub1780:printw$:poke53280,15:goto1090
1140 ifz$="y"orz$="[217]"then60
1150 ifz$<>"n"andz$<>"[206]"then1090
1160 goto40000
1170 rem calc new white position number
1180 a3=fnt(w%(1))+fnt(w%(2))+fnt(w%(3)):s3=1
1190 ifs%(s3)=a3then1210
1200 s3=s3+1:ifs3<166then1190
1210 return
1220 rem pick reds best move
1230 m4=0:fori4=1to11:ifl%(b,i4)=0then1310
1240 rem neighbor square found. white occupied?
1250 j4=1
1260 ifw%(j4)=i4then1310
1270 j4=j4+1:ifj4<4then1260
1280 ifm4=0then1300
1290 ifa%(s3,m4)>=a%(s3,i4)then1310
1300 m4=i4
1310 next:return:rem reds best move
1320 rem data for l%(i,j) array
1330 rem l%(i,j)=0 means i to j not legal
1340 rem l%(i,j)=1 means i to j legal fox only
1350 rem l%(i,j)=2 means i to j legal both hound and fox
1360 data0,2,2,2,0,0,0,0,0,0,0
1370 data1,0,2,0,2,2,0,0,0,0,0
1380 data1,2,0,2,0,2,0,0,0,0,0
1390 data1,0,2,0,0,2,2,0,0,0,0
1400 data0,1,0,0,0,2,0,2,0,0,0
1410 data0,1,1,1,2,0,2,2,2,2,0
1420 data0,0,0,1,0,2,0,0,0,2,0
1430 data0,0,0,0,1,1,0,0,2,0,2
1440 data0,0,0,0,0,1,0,2,0,2,2
1450 data0,0,0,0,0,1,1,0,2,0,2
1460 data0,0,0,0,0,0,0,1,1,1,0
1470 print"[147]";tab(12);"[198][207][216] [193][206][196] [200][207][213][206][196][211]"
1480 printtab(11);"[185][185][185][185] [185][185][185][185] [185][185][185][185]"
1490 printtab(10);"[172] [191] [172] [191] [172] [191]"
1500 printtab(10);"[172] [194] [165][185][188] [197] [165][185][188] [200] [191]"
1510 printtab(10);"[172] [191] [172] [191] [172] [191]"
1520 printtab(10);"[172] [191] [172] [191] [172] [191]"
1530 printtab(10);"[181][176][180][176][176][162] [176][180][176][176] [181][176][180][176][176][162]"
1540 printtab(9);"[181] [172] [162] [172] [181] [172] [162]"
1550 printtab(4);"[185][185][185][185][181] [185][188][185][185] [162][185][188][185][185][181] [185][188][185][185] [162][185][185][185][185]"
1560 print" [172][197][216][201][212][144][191] [172] [191] [172] [191] [172] [191] [172] [196][197][206][144][191]"
1570 print" [172] [193] [165][185][188] [195] [165][185][188] [198] [165][185][188] [201] [165][185][188] [203] [191]"
1580 print" [172] [191] [172] [191] [172] [191] [172] [191] [172] [191]"
1590 print" [172] [191] [172] [191] [172] [191] [172] [191] [172] [191]"
1600 printtab(4);"[176][176][176][176][162] [176][180][176][176] [181][176][180][176][176][162] [176][180][176][176] [181][176][176][176][176]"
1610 printtab(9);"[162] [172] [181] [172] [162] [172] [181]"
1620 printtab(10);"[162][185][188][185][185][181] [185][188][185][185] [162][185][188][185][185][181]"
1630 printtab(10);"[172] [191] [172] [191] [172] [191]"
1640 printtab(10);"[172] [196] [165][185][188] [199] [165][185][188] [202] [191]"
1650 print" [205]ove";i0;tab(10);"[172] [191] [172] [191] [172] [191]"
1660 printtab(10);"[172] [191] [172] [191] [172] [191]"
1670 printtab(10);" [176][176][176][176] [176][176][176][176] [176][176][176][176]"
1680 fori=1to3:z=w%(i):gosub1780:printw$:next
1690 ifn=1then1760
1700 r=21:c=0:gosub1900:print"[208]lace fox on empty square.":j=1:poke198,0
1710 geta$:ifa$=""then1710
1720 f$="cefghijk":ifa$>"[193]"thena$=chr$(asc(a$)-128)
1730 fori=1to8:ifa$=mid$(f$,i,1)thenj=i+1:r=21:c=0:gosub1900:printb1$
1740 next:ifj=1goto1710
1750 b=asc(a$)-64
1760 z=b:gosub1780:printr$
1770 return
1780 onzgoto1790,1800,1810,1820,1830,1840,1850,1860,1870,1880,189